package javaconfig;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Scope;

//我是一个配置类，我将取代beans.xml文件
@Configuration
public class MyBeanConfig {

    //往容器中注册一个userDao，方法名字就是bean的命名
    @Bean
    @Scope("prototype")
    public UserDao userDao(){
        return new UserDao();
    }



    //往容器中注册一个userService 方法名字就是bean的命名
    @Bean
    @Scope("prototype")
    public UserService userService(){
       // return new UserService();
        UserService userService=new UserService();
        userService.setUserDao(userDao());

        return userService;
    }



}
